/*
 * @Author: liuYang codkly@gmail.com
 * @Date: 2022-12-06 16:48:25
 * @LastEditors: liuYang codkly@gmail.com
 * @LastEditTime: 2022-12-07 09:35:36
 * @FilePath: \coding\nest\blog_alpha\src\article\article.controller.ts
 * @Description:
 * 暂无备注
 */
import {
  Controller,
  Post,
  Body,
  UseGuards,
  Request,
  HttpCode,
  Get,
  Delete,
  Put,
  Param,
  Query,
} from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { ArticleService } from './article.service';

@Controller('article')
export class ArticleController {
  constructor(private readonly articleService: ArticleService) {}
  // 列表
  @Get()
  @ApiOperation({ summary: '列表' })
  async findAll(@Query() query: any): Promise<any> {
    return await this.articleService.findAll(query);
  }
  // 获取用户信息
  @Get(':id')
  @ApiOperation({ summary: '用户信息' })
  getProfile(@Param() params: any) {
    return this.articleService.findOne(params.id);
  }

  // 增加
  @Post()
  @HttpCode(200)
  @ApiOperation({ summary: '增加' })
  async create(@Body() createUserDto: any): Promise<any> {
    return await this.articleService.create(createUserDto);
  }

  // 删除
  @Delete()
  @ApiOperation({ summary: '删除' })
  async remove(@Body() removeUserDto: any, @Request() req): Promise<any> {
    return await this.articleService.delete(removeUserDto);
  }

  // 更新
  @Put(':id')
  @ApiOperation({ summary: '更新' })
  async update(@Param() params: any, @Body() updateUserDto: any): Promise<any> {
    return await this.articleService.update({
      id: params.id,
      updateUserDto,
    });
  }
}
